"use strict";
var path      = require("path");
var env       = process.env.NODE_ENV || "development";
var config    = require(path.join(__dirname, '..', 'config', 'config.json'))[env];
var genericPool = require('generic-pool');
var DbDriver = require('mysql');

var factory = {
  create: function() {
    return DbDriver.createConnection(config)
  },
  destroy: function(client) {
    client.end();
  }
};

var opts = {
    max: 30,
    min: 2,
    idleTimeoutMillis : 30000
}

var pool = genericPool.createPool(factory, opts)


module.exports = pool;
